package com.iwhalecloud.bss.kite.cucc.web.controller.attr;

import com.github.pagehelper.PageInfo;
import com.iwhalecloud.bss.kite.client.dto.DataResult;
import com.iwhalecloud.bss.kite.common.constant.ErrorConsts;
import com.iwhalecloud.bss.kite.cucc.client.api.inf.IInfServiceBus;
import com.iwhalecloud.bss.kite.cucc.client.dto.order.SaleManageDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName : SalesmanController
 * @Description : 销售人员
 * @Author : xie.zhengjun
 * @Date : 2020/9/19 20:26
 */
@Api(tags = {"/salesman - 销售人员"})
@RestController
@RequestMapping("/salesman")
public class SalesmanController {
    @Resource
    private IInfServiceBus infServiceBus;

    @ApiOperation(value = "查询销售人员", notes = "查询销售人员")
    @ApiImplicitParams({@ApiImplicitParam(name = "staffId", value = "员工标识"),
        @ApiImplicitParam(name = "channelId", value = "渠道标识"), @ApiImplicitParam(name = "name", value = "名称"),
        @ApiImplicitParam(name = "origDomain", value = "origDomain"),
        @ApiImplicitParam(name = "productType", value = "产品类型")
    })
    @GetMapping("/list")
    public DataResult<List<SaleManageDTO>> querySalesman(String staffId, String channelId, String name,
        String origDomain, String productType) {
        return ErrorConsts.SUCCESS
            .getResult(infServiceBus.querySaleManager(staffId, channelId, name, origDomain, productType));
    }

    @ApiOperation(value = "分页查询销售人员", notes = "分页查询销售人员")
    @ApiImplicitParams({@ApiImplicitParam(name = "staffId", value = "员工标识"),
        @ApiImplicitParam(name = "channelId", value = "渠道标识"), @ApiImplicitParam(name = "name", value = "名称"),
        @ApiImplicitParam(name = "origDomain", value = "origDomain"),
        @ApiImplicitParam(name = "productType", value = "产品类型"),
        @ApiImplicitParam(name = "pageNum", value = "当前页"),
        @ApiImplicitParam(name = "pageSize", value = "页面大小")
    })
    @GetMapping("/querySalesPerson")
    public DataResult<PageInfo<SaleManageDTO>> querySalesPerson(@RequestParam(required = false) String staffId,
                                                                @RequestParam(required = false) String channelId,
                                                                @RequestParam(required = false) String name,
                                                                @RequestParam(required = false) String origDomain,
                                                                @RequestParam(required = false) String productType,
                                                                @RequestParam(required = true) int pageNum,
                                                                @RequestParam(required = true) int pageSize) {
        return ErrorConsts.SUCCESS
            .getResult(infServiceBus.querySalesPerson(staffId, channelId, name, origDomain, productType, pageNum, pageSize));
    }
}
